<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>测试添加订单</title>
</head>
<body>
    <script src="js/jquery-3.2.1.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            alert("start");
            addOrder();
            alert("end");
        });

        function addOrder() {
            alert("进入方法");

            var orderDetailList=new Array();
            orderDetailList.push({
                "detailId" : "8c1a14d3449011e8b59100163e062fc6",// TODO
                "receipt" : 100.0,// TODO
                "num" : 1,// TODO
                "promotionId" : "9999"// TODO
            });
            orderDetailList.push({
                "detailId" : "bdab78fc449011e8b59100163e062fc6",// TODO
                "receipt" : 88.0,// TODO
                "num" : 2,// TODO
                "promotionId" : ""// TODO
            });

            var itemNum = 0;
            for (var i=0;i<orderDetailList.length;i++)
                itemNum+=orderDetailList[i].num;

            var order={
                "vipId" : "123", // TODO
                "payWay" : "支付宝",// TODO
                "itemNum" : itemNum,
                "promotionId" : ""// TODO
            };

            var params = {
                "order" : order,
                "orderDetailList" : orderDetailList,
            };

            alert(JSON.stringify(params));

            $.ajax({
                url : '/ClothesShopPOS/ordertot/add',
                type: "POST",
                contentType : "application/json;charset=utf-8",
                dataType : "json",
                data : JSON.stringify(params),
                success : function(data) {
                    console.log(data);
                    data = JSON.parse(data);
                    if (data.statusCode=='0')
                        alert("添加成功");
                    else
                        alert("添加失败");
                }
            })
        }
    </script>
</body>
</html>